#include <bits/stdc++.h>

using namespace std;

int n;

int main()
{
    vector<int> a;
    int tmp;
    while (cin >> tmp)
    {
        a.push_back(tmp);
    }
    vector<int> g, f(a.size(), 0);
    int ret = 0;
    for (int i = 0; i < a.size(); i++)
    {
        f[i] = 1;
        for (int j = 0; j < i; ++j)
        {
            if (a[i] <= a[j])
            {
                f[i] = max(f[i], f[j] + 1);
            }
        }
        ret = max(ret, f[i]);
        int k = 0;
        while (k < g.size() && g[k] < a[i])
        {
            k++;
        }
        if (k == g.size())
        {
            g.push_back(a[i]);
        }
        else
        {
            g[k] = a[i];
        }
    }
    cout << ret << endl;
    cout << g.size() << endl;
    return 0;
}